package com.ziyia.activity;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

public class getData extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_get_data);

        String data = getIntent().getStringExtra("data");
        if (data != null) {
            Toast.makeText(getData.this, "接收到的数据 = " + data, Toast.LENGTH_SHORT).show();
        }
    }

    /**
     * 点击返回键回调
     */
    @Override
    public void onBackPressed() {
        resultDataToActivity();
    }

    public void load(View view) {
        switch (view.getId()) {
            case R.id.one:
                resultDataToActivity();
                break;
        }
    }

    private void resultDataToActivity() {
        Intent intent = new Intent();
        intent.putExtra("result_data", "我这边的事件处理完了");
        setResult(RESULT_OK, intent);
        finish();
    }
}